package com.c2c.converter;

import com.c2c.po.enums.impl.UsersState;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class UserStateConverter implements Converter<String, UsersState> {

    @Override
    public UsersState convert(String string) {
        for (UsersState usersState: UsersState.values()) {
            if (usersState.getCode() == Integer.parseInt(string)){
                return usersState;
            }
        }
        return null;
    }
}
